home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7363 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: newsfeed.direct.ca!usenet
  2. From: etoivane@direct.ca (Ed Toivanen)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Binary files ?
  5. Date: 25 Feb 1996 22:05:29 GMT
  6. Organization: Your Organization
  7. Message-ID: <4gqmf9$jno@aphex.direct.ca>
  8. References: <4gheee$bvr@ci.ist.utl.pt>
  9. NNTP-Posting-Host: 204.174.243.150
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.6
  13.  
  14.  
  15. ># include <stdio.h>
  16. >
  17. >
  18. >void main()
  19. >{
  20. > /*write file*/
  21. > int n;
  22. > unsigned char mat[200]; 
  23. > FILE *f=fopen("teste","w");              
  24.       should be "w+b"
  25. > for (n=0;n<200;n++) mat[n]=n; /*init matrix*/
  26. > fwrite(mat,200,1,f);
  27. > fclose(f);
  28. >
  29. > /*reset matrix*/
  30. > for (n=0;n<200;n++) mat[n]=0;
  31. >
  32. > /*read file*/
  33. > f=fopen("teste","r");
  34.        don't open it again
  35. > fread(mat,200,1,f);
  36.        middle two params reversed
  37. > fclose(f);
  38. > for (n=0;n<200;n++) printf("%d ",mat[n]);/*print it*/
  39. >}
  40.  
  41. Just a quick pass, I still might have missed something
  42. Ed
  43.  
  44. >
  45. >// The main difference between man and animal is that man possesses the \\
  46. >//hability to think he is rational...                                   \\
  47. >E-mail : l40128@alfa.ist.utl.pt
  48. >
  49.  
  50.